//package com.pic.others.handler;
//
//import cn.hutool.json.JSONUtil;
//import com.alibaba.fastjson.JSONObject;
//import com.pic.common.utils.UserContext;
//import com.pic.others.constants.category.ConnectionFlaskConstant;
//import com.pic.others.domain.dto.flask.FlaskSimilarResDTO;
//import com.pic.others.domain.dto.picture.PictureSimilarFlaskDTO;
//import com.pic.others.domain.po.Picture;
//import com.pic.others.domain.po.RecommendSimilarPicture;
//import com.pic.others.mapper.PictureMapper;
//import com.pic.others.mapper.RecommendSimilarPictureMapper;
//import com.pic.others.service.IPictureService;
//import com.pic.others.service.IRecommendSimilarPictureService;
//import com.pic.others.utils.ConnectionFlaskUtils;
//import com.xxl.job.core.handler.annotation.XxlJob;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//
//import java.util.Collections;
//import java.util.HashSet;
//import java.util.List;
//import java.util.Set;
//
//@Slf4j
//@Component
//@RequiredArgsConstructor
//public class AutoPictureHandler {
//    private final PictureMapper pictureMapper;
//    private final IPictureService pictureService;
//    private final IRecommendSimilarPictureService recommendSimilarPictureService;
//    private final RecommendSimilarPictureMapper recommendSimilarPictureMapper;
//
//    @Value("${flask.hosturl1}")
//    private String ConnectionFlask;
//
//
//    //自动推荐相似图片
//@XxlJob("RecommendSimilarPicture")
//    public void recommendSimilarPicture(){
//    log.info("进去了");
//    long userId = 1738921287630561281L;
//    List<Picture> pictures = Collections.unmodifiableList(pictureService.lambdaQuery().eq(Picture::getUserId, userId).list());
//    Set<RecommendSimilarPicture> dtos = new HashSet<>();
//    if(pictures==null)
//        return;
//
//    for (int i = 0; i < pictures.size(); i++) {
//        for (int j = i + 1; j < pictures.size(); j++) {
//            FlaskSimilarResDTO resDTO = new FlaskSimilarResDTO(pictures.get(i).getLocate(), pictures.get(j).getLocate());
//            String data = ConnectionFlaskUtils.getConnectionFlask(ConnectionFlaskConstant.urlPath.GET_SIMILAR_PICTURE,
//                    ConnectionFlaskConstant.method.POSTMAPPING,
//                    "data", resDTO);
//            log.info(data);
//            if("True".equals(data)){
//                RecommendSimilarPicture similarPicture=new RecommendSimilarPicture();
//                similarPicture.setUserId(userId);
//                similarPicture.setPictureId(pictures.get(i).getPicId());
//                similarPicture.setLocate(pictures.get(i).getLocate());
//                dtos.add(similarPicture);
//                RecommendSimilarPicture similarPicture2=new RecommendSimilarPicture();
//                similarPicture2.setUserId(userId);
//                similarPicture2.setPictureId(pictures.get(j).getPicId());
//                similarPicture2.setLocate(pictures.get(j).getLocate());
//
//                dtos.add(similarPicture2);
//            }
//        }
//    }
//    for(RecommendSimilarPicture save:dtos){
//        recommendSimilarPictureService.save(save);
//    }
//}
//
//
//
//
//}
